import { defineStore } from 'pinia'
/**基础信息*/
export const {MODE, VITE_APP_BASE_URL, BASE_URL} = import.meta.env
export const BASE_TITLE = '书籍管理系统'
export const BASE_NAME = 'dkmk-peis-manage'
export const BASE_SHORTNAME = 'peis'
export const UseSuffix = false
export const ORIGIN_URL = location && location.origin ? location.origin : VITE_APP_BASE_URL
export const BASE_API_URL = UseSuffix ? ORIGIN_URL + '/' + BASE_SHORTNAME : ORIGIN_URL

interface Colors{
  theme:string
  grey:string
  white:string
  red:string
}
interface Basic{
  colors:Colors
}
/**配置 */
interface Layout{
  //是否收缩布局(小屏)
  shrink:boolean
  //布局方式
  layoutMode:string
  //侧边栏是否收缩
  menuCollapse:boolean
  //是否全屏
  fullScreen:boolean
}
interface ConfigState{
  //基础数据
  basic:Basic
  //布局
  layout:Layout
}

const configStore = defineStore('configStore', {
  state:():ConfigState => {
    return {
      basic:{
        colors:{
          theme:'1C9399',
          grey:'#303133',
          white:'#FFFFFF',
          red:'E13848'
        }
      },
      layout:{
        shrink:false,
        layoutMode:'no',
        menuCollapse:false,
        fullScreen:false
      }
    }
  },
  actions:{
    changeFullScreen(fullScreen:boolean) {
      this.layout.fullScreen = fullScreen
    }
  }
})

export default {
  setup() {
    const store = configStore()
    return {store}
  }
}